package com.huangjian.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

@Configuration
//开启swagger2
@EnableSwagger2
public class SwaggerConfig {

     @Bean
     public Docket docker1(){
         return new Docket(DocumentationType.SWAGGER_2).groupName("A");
     }
     @Bean
    public Docket docker2(){
        return new Docket(DocumentationType.SWAGGER_2).groupName("B");
    }
    @Bean
    public Docket docker3(){
        return new Docket(DocumentationType.SWAGGER_2).groupName("C");
    }

      @Bean
      public Docket docket(){
           return new Docket(DocumentationType.SWAGGER_2)
                   .groupName("huangjian")
                   .apiInfo(apiInfo())
                   .enable(true)    //是否可以在浏览器中访问swagger，默认true
                   .select()
                   // RequestHandlerSelectors配置要扫描接口的方式，basePackage指定要扫描的包
                   .apis(RequestHandlerSelectors.basePackage("com.huangjian.controller"))
                   //过滤huangjian下的所有请求
                   //.paths(PathSelectors.ant("/huangjian/**"))
                   .build();
      }

      //配置swagger的apiInfo
      public ApiInfo apiInfo(){

          //作者信息
          Contact contact=new Contact("幻墨如烟","http://www.huangjian.site","2502442847@qq.com");

           return new ApiInfo("幻墨如烟的Swagger Api文档",
                  "船到桥头自然沉",
                  "v1.0",
                  "http://www.huangjian.site",
                   contact,
                  "Apache 2.0",
                  "http://www.apache.org/licenses/LICENSE-2.0",
                  new ArrayList());
      }

}
